package com.heima.wemedia.service.impl;


import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.wemedia.entity.WmChannel;
import com.heima.model.wemedia.entity.WmNews;
import com.heima.wemedia.dao.WmChannelDao;
import com.heima.wemedia.service.WmChannelService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 自媒体频道表(WmChannel)表服务实现类
 *
 * @author makejava
 * @since 2022-04-12 15:48:48
 */
@Service("wmChannelService")
public class WmChannelServiceImpl implements WmChannelService {
    @Resource
    private WmChannelDao wmChannelDao;



    @Override
    public List<WmChannel> selectChannels() {
        return wmChannelDao.selectAll();
    }

    @Override
    public ResponseResult selectById(Long id) {
        WmNews wmNews = wmChannelDao.queryById(id);
        if(wmNews==null){
            return ResponseResult.errorResult(AppHttpCodeEnum.DATA_NOT_EXIST);
        }
        return ResponseResult.okResult(wmNews);
    }


}
